﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Customers;

namespace PMS.Data.EntityMap.Customers
{
    /// <summary>
    /// Represents a ExternalAuthenticationRecord mapping configuration
    /// </summary>
    public partial class ExternalAuthenticationRecordMap : PMSEntityTypeConfiguration<ExternalAuthenticationRecord>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<ExternalAuthenticationRecord> builder)
        {
            builder.ToTable("bus_externalauthenticationrecord");
            builder.HasKey(externalauth => externalauth.Id);

            builder.Property(externalauth => externalauth.CustomerId).IsRequired();
            builder.Property(externalauth => externalauth.Mobile).HasMaxLength(32);
            builder.Property(externalauth => externalauth.Email).HasMaxLength(128);
            builder.Property(externalauth => externalauth.ExternalIdentifier).HasMaxLength(3072).IsRequired();
            builder.Property(externalauth => externalauth.ExternalIdentifierName).HasMaxLength(32).IsRequired();
            builder.Property(externalauth => externalauth.OAuthAccessToken).HasMaxLength(3072);
            builder.Property(externalauth => externalauth.ProviderSystemName).HasMaxLength(128).IsRequired();

            builder.Ignore(externalauth => externalauth.IsActive);
            base.Configure(builder);
        }

        #endregion
    }
}
